#!/data/data/com.termux/files/usr/bin/bash
#WorkShopDownloader #创意工坊下载器
clear
read -p "请输入STEAM模组ID或URL：" INPUT
if [ ! $INPUT ] ; then
echo "啥也没发生！"
exit
fi
steam_id=`echo $INPUT | sed 's/http.*id=\([0-9]*\)&.*/\1/'`
json=`wget -qO- "https://5.5w.pw/api?mid=$steam_id"`
title=`echo $json | sed 's/.*"title":"\([^,}]*\)".*/\1/'`
url=`echo $json | sed 's/.*"url":"\([^,}]*\)".*/\1/'`
printf "正在下载……\n"
printf "title：$title\n"
printf "url：$url\n"
wget -qO "/sdcard/download/[M]$title.ZIP" "$url"
printf "下载完成，已保存文件/sdcard/download/[WSD]$title.ZIP\n"